package com.ParkingManager.app.carPlateRecognition;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Vector;

public class carPlateRecognition {
	public static String[] carPlateRec(String path)
	{
		String command="python "+System.getProperty("user.dir")+"\\src\\main\\python\\carPlateRecognition.py -i "+path;
		Runtime rt=Runtime.getRuntime();
		Vector<String> res = new Vector<String>();
		 try {
			   System.out.println("start");
			   Process pr = Runtime.getRuntime().exec(command);
			   BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream(),"GBK"));
			   String line;
			   while ((line = in.readLine()) != null) {
			    System.out.println(line);
			    res.add(line);
			   }
			   in.close();
			   pr.waitFor();
			  } catch (Exception e) {
			   e.printStackTrace();
			  }
		if(res.size()==5)
		{
			String result[]=new String[2];
			result[0]=res.get(3);//获取车牌字符
			result[1]=res.get(4);//获取车型
			System.out.println(result[0]);
			System.out.println(result[1]);
			return result;
		}
		else return null;
	}

}


